import json
with open("data_2_layers.json", "r", encoding="utf-8" ) as f:
    text = json.load(f)
sum = 0
for i, d in enumerate(text['children']):
    sum += i - d['id']
print(sum)